#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
const int N = 100001;

struct Line{
    LL x1,x2;
    LL y;
    int tag;
    Line(){}
    Line(LL x1_,LL x2_,LL y_,int tag_):x1{x1_},x2{x2_},y{y_},tag{tag_}{}
    bool operator< (const Line& line)const{
        return this->y<line.y;
    }
};

struct Node{
    int cnt,len;
    Node(){}
};
Line lines[2*N];
Node tree[8*N];
LL x[2*N];
int n;
LL x11,y11,x22,y22;

void build(int idx,int l,int r){
    tree[idx].cnt = tree[idx].len = 0;
    if(l==r) return;
    int mid = (r-l)/2+l;
    build(2*idx,l,mid);
    build(2*idx+1,mid+1,r);
}

void push_up(int u,int l,int r){
    if(tree[u].cnt){
        tree[u].len = x[r+1] - x[l];
    }
    else{
        tree[u].len = tree[2*u].len + tree[2*u+1].len;
    }
}

void add(int idx,int l,int r,const LL L,const LL R,const int v){
    if(x[l]>=R || x[r+1]<=L) return;
    if(L<=x[l] && x[r+1]<=R){
        tree[idx].cnt += v;
        push_up(idx,l,r);
        return;
    }
    int mid = (r-l)/2+l;
    add(2*idx,  l,mid,L,R,v);
    add(2*idx+1,mid+1,r,L,R,v);
    push_up(idx,l,r);
}

int main(){
    scanf("%d",&n);
    for(int i=1;i<=n;i++){
        scanf("%lld%lld%lld%lld",&x11,&y11,&x22,&y22);
        lines[i] = Line(x11,x22,y11,1);
        lines[i+n] = Line(x11,x22,y22,-1);
        x[i] = x11;
        x[i+n] = x22;
    }
    sort(x+1,x+2*n+1);
    int m = unique(x + 1, x + 2 * n + 1) - (x + 1);
    sort(lines+1,lines+2*n+1);
    build(1,1,m-1);

    LL ans = 0;
    for(int i=1;i<2*n;i++){
        add(1,1,m-1,lines[i].x1,lines[i].x2,lines[i].tag);
        ans += (LL)tree[1].len * (lines[i+1].y-lines[i].y);
    }
    printf("%lld\n",ans);
    return 0;
}